package cn.xhh.dailyreview.server.utils;


import java.io.File;
import java.util.HashMap;
import java.util.Map;

import org.junit.After;
import org.junit.Before;

import com.google.appengine.tools.development.ApiProxyLocalImpl;
import com.google.apphosting.api.ApiProxy;
import com.google.apphosting.api.ApiProxy.Environment;

/**
 * Extend this class for tests using features of Google App Engine.
 * @author cooky
 */
public class ConfigGAE implements Environment{
	
	@Before
	public void before() throws Exception {
		ApiProxy.setEnvironmentForCurrentThread(new ConfigGAE());
        ApiProxy.setDelegate(new ApiProxyLocalImpl(new File(".")){});
	}

	@After
	public void after() throws Exception {
		ApiProxy.setDelegate(null);
        ApiProxy.setEnvironmentForCurrentThread(null);
	}

	@Override
	public String getAppId() {
		return "daily-review";
	}

	@Override
	public Map<String, Object> getAttributes() {
		return new HashMap<String, Object>();
	}

	@Override
	public String getAuthDomain() {
		throw new UnsupportedOperationException();
	}

	@Override
	public String getEmail() {
		throw new UnsupportedOperationException();
	}

	@Override
	public String getRequestNamespace() {
		return "";
	}

	@Override
	public String getVersionId() {
		return "1.0";
	}

	@Override
	public boolean isAdmin() {
		throw new UnsupportedOperationException();
	}

	@Override
	public boolean isLoggedIn() {
		throw new UnsupportedOperationException();
	}

}
